from google.appengine.ext import db

class Usuario(db.Model):
	user  = db.UserProperty()
	nome  = db.StringProperty()
	id    = db.StringProperty()
	email = db.StringProperty()
	def getCurrentUser(self):
		from appengine_utilities.sessions import Session	
		self.session = Session()
		user = ""
		if 'user' in self.session:
			user = self.session['user']
		return user	
	
class Proposta(db.Model):	
   autor     = db.ReferenceProperty(Usuario)
   descricao = db.TextProperty()
   data      = db.DateTimeProperty(auto_now_add=True)
   titulo    = db.StringProperty()
   categoria = db.StringProperty()
   tags      = db.StringListProperty()
   cont      = db.IntegerProperty()
   url       = db.StringProperty()
   site      = db.StringProperty()
   siteUrl   = db.StringProperty()
   siteName  = db.StringProperty()
   created   = db.IntegerProperty()
   rank      = db.IntegerProperty()

class Voto(db.Model):
   autor = db.ReferenceProperty()
   proposta = db.StringProperty()
   data = db.DateTimeProperty(auto_now_add=True)

class Comment(db.Model):
   autor = db.ReferenceProperty()
   comentario = db.TextProperty()
   proposta = db.StringProperty()
   data = db.DateTimeProperty(auto_now_add=True)
   titulo = db.StringProperty()
  
class Feed(db.Model):
   titulo = db.StringProperty()
   conteudo = db.TextProperty()